package jass.iss.edu.Properties;

import java.io.IOException;
import java.util.Properties;

public class JobAdvertisementDAO extends PropertiesDAO<JobAdvertisementDTO> {
	
	public JobAdvertisementDAO() throws IOException {
		super("jobadvertisement.properties");

	}
	

	
	@Override
	protected JobAdvertisementDTO read(Properties pProp, String pID) {
		JobAdvertisementDTO advert = new JobAdvertisementDTO(pID);
		advert.setPosition(pProp.getProperty("Position"+pID));
		advert.setReferenceID(pProp.getProperty("ReferenceID"+pID));
		advert.setJobDescription(pProp.getProperty("Job_Description"+pID));
		advert.setRequirements(pProp.getProperty("Requirements"+pID));
		advert.setAdvertisedDate(getDateFromString(pProp.getProperty("Advertised_Date"+pID)));
		advert.setClosingDate(getDateFromString(pProp.getProperty("Closing_Date"+pID)));
		advert.setSalaryRange(pProp.getProperty("Salary_Range"+pID));
		advert.setAlternateDescription(pProp.getProperty("Alternate_Description"+pID));
		advert.setJobAdvertStatus(pProp.getProperty("Job_Advert_Status"+pID));
		advert.setPostedDate(getDateFromString(pProp.getProperty("Posted_Date"+pID)));
		advert.setResponsibilities(pProp.getProperty("Responsibilities"+pID));
		return advert;
	}



	@Override
	protected void write(Properties prop, JobAdvertisementDTO dto) {
		String strID = dto.getId();
		prop.setProperty( "Position"+strID,  dto.getPosition());
		prop.setProperty( "ReferenceID"+strID,  dto.getReferenceID());
		prop.setProperty( "Job_Description"+strID,  dto.getJobDescription());
		prop.setProperty( "Requirements"+strID,  dto.getRequirements());
		prop.setProperty( "Advertised_Date"+strID,  getStringFromDate(dto.getAdvertisedDate()));
		prop.setProperty( "Closing_Date"+strID, getStringFromDate(dto.getClosingDate()));
		prop.setProperty( "Salary_Range"+strID,  dto.getSalaryRange());
		prop.setProperty( "Alternate_Description"+strID,  dto.getAlternateDescription());
		prop.setProperty( "Job_Advert_Status"+strID,  dto.getJobAdvertStatus());
		prop.setProperty( "Posted_Date"+strID,getStringFromDate(dto.getPostedDate()));
		prop.setProperty( "Responsibilities"+strID,  dto.getResponsibilities());
	}

	

}
